<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/common/taglib.jsp" %>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="微社区,Q生活" name="keywords"/>
<meta content="微社区,Q生活" name="description"/>
<title>微社区|Q生活</title>
<link rel="stylesheet" href="${ctx }/static/css/Master.css"/>

<script src="${ctx }/static/js/jquery-1.9.0.min.js"></script>
<script src="${ctx}/static/plugins/layer/layer.js"></script>
<%-- 基础js,所有页面都需要引入此js,依赖layer.js --%>
<script src="${ctx}/static/js/common/base.js"></script>
<script src="${ctx}/static/js/common/util.js"></script>
<script type="text/javascript">
$(function(){
	$(".btn-delete").click(function() {
        var id = $(this).data("id");
        var name = $(this).data("name");
    	top.layer.confirm('确认将用户"'+name+'"强制退出登录吗?', {icon: 3}, function(index){
            $.ajax({    
    		    url:"${ctx}/monitor/online/"+id+"/forceLogout",   
    		    data:"",    
    		    type:"get",    
    		    cache:false,    
    		    dataType:"json",
    		    async:true, //默认为true 异步    
    		    success:function(data) {
    	            top.layer.msg(data,{},function(){
    	                window.location.reload();  
    	            });
    		     }  
    		});
    	});

    });
});
</script>
</head>

<body class="utilSubmit">
<section class="boxRight">
<form id="searchForm" method="get" >
<div class="context boxborder">

	<!-- 内容 -->
	当前在线人数：${sessionCount}
	<div class="com_table">
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<th>序号</th>
				<th>用户名</th>
				<th>会话ID</th>
				<th>IP</th>
				<th>登录时间</th>
				<th>最后访问时间</th>
				<th>状态</th>
				<th>用户代理</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${sessions}" var="session" varStatus="status">
			<tr>
				<td>${status.count}</td>
				<td>${diy:getUserRealNameBySession(session)}</td>
				<td>${session.id}</td>
				<td>${session.host}</td>
				<td>
					<div class="utilTips">
						<pretty:prettyTime date="${session.startTimestamp}"/>
                		<div class="utilTipsText" style="display: none;"><fmt:formatDate value="${session.startTimestamp}" pattern="yyyy-MM-dd HH:mm:ss" /></div>
					</div>
				</td>
				<td>
					<div class="utilTips">
						<pretty:prettyTime date="${session.lastAccessTime}"/>
                		<div class="utilTipsText" style="display: none;"><fmt:formatDate value="${session.lastAccessTime}" pattern="yyyy-MM-dd HH:mm:ss" /></div>
					</div>
				</td>
				<td>${diy:getSessionStatus(session)}</td>
				<td>
					<div class="utilTips">
						${session.getAttribute('User-Agent').length()>20?session.getAttribute('User-Agent').substring(0,20).concat(" ..."):session.getAttribute('User-Agent')}
						<c:if test="${session.getAttribute('User-Agent').length()>20}">
                		<div class="utilTipsText" style="display: none;">${session.getAttribute("User-Agent") }</div>
                		</c:if>
					</div>
				</td>
				<td>
					<shiro:hasPermission name="monitor:online:delete">
					<a class="icon micon_20 btn-delete" data-name="${diy:getUserRealNameBySession(session)}" data-id="${session.id}" title="强制退出" href="javascript:void(0)"></a>
					</shiro:hasPermission>
				</td>
			</tr>
			</c:forEach>
		</table>
		
	</div>
</div>
</form>
</section>
</body>
</html>
